﻿using UnityEngine;
using System.Collections;

public class OwnerObj
{
    private IWorldObject ownerObj = null;

    private OwnerObj(IWorldObject ownerObj)
    {
        this.ownerObj = ownerObj;
    }

    public static OwnerObj CreateNew(IWorldObject ownerObj)
    {
        return new OwnerObj(ownerObj);
    }

    public void Set(IWorldObject ownerObj)
    {
        this.ownerObj = ownerObj;
    }

    public bool IsNull()
    {
        return (null == ownerObj);
    }

    public bool Is<T>()
    {
        if (ownerObj is T)
        {
            return true;
        }

        return false;
    }

    public T Get<T>()
    {
        if (ownerObj is T)
        {
            return (T)((object)ownerObj);
        }

        return default(T);
    }
    
}
